var typeVue = new Vue({
	el:"#app",
	data:{
		types:[],
		details:[]
	},
	methods:{
		init:function(id){
			var t = this;
			wx.showLoading({
				title: "加载中",
				mask: !0
			});
			this.$http.get(baseUrl + "productTypeCode/query").then(function(a) {
				wx.hideLoading();
				var i = a.data;
				if (!i.success) return wx.hideLoading(), wx.showToast({
					title: i.description,
					icon: "none",
					duration: 2e3,
					mask: !0
				}), !1;
				if(id){
					i.data.forEach(function(e){
						if(e.typeId == id){
							e.active = true;
							t.details = e.children;
						}
					});
				}else{
					i.data.forEach(function(e,index){
						if(index==0){
							e.active = true;
							t.details = e.children;
						}
					});
				}
				t.details.forEach(function(e){
					if(e.imgUrl){
						e.imgUrl = e.imgUrl.replace('http://mjz.yitavc.com/static/', '../../images/');
					}
				});
				t.types = i.data;
				t.types.forEach(function(e){
					if(e.imgUrl){
						e.imgUrl = e.imgUrl.replace('http://mjz.yitavc.com/static/', '../../images/');
					}
				});
			}).catch(function(t) {
				wx.hideLoading();
				wx.showToast({
					title: "网络错误，请检查网络",
					icon: "none",
					duration: 2e3,
					mask: !0
				});
			});
		},
		getData:function(item){
			var t = this;
			item.active = true;
			var types = t.types;
			types.forEach(function(e){
				if(e.typeId == item.typeId){
					e.active = true;
					t.details = e.children;
					if(t.details){
						t.details.forEach(function(e){
							e.imgUrl = e.imgUrl.replace('http://mjz.yitavc.com/static/', '../../images/');
						});
					}
				}else{
					e.active = false;
				}
			});
		},
		toProducts:function(item){
			Jump.to(page.product.type_detail,"typeId="+item.typeId+"&title="+item.name,"typeId="+item.pTypeId);
		}
		
	},
	created:function(){
		var typeId = URLParam.get("typeId");
		this.init(typeId);
	}
});